package com.example.validdemo.config;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;

import javax.validation.Validation;
import javax.validation.Validator;

/**
 * @author huboxin
 * @date 2021-9-279:23
 */
//@Configuration
public class CommonConfiguration {

    /**
     * 快速失败模式
     *
     * @return Validator
     */
    @Bean
    public Validator getValidator() {
        return Validation.byProvider(HibernateValidator.class)
                .configure()
                .failFast(true)
                .buildValidatorFactory()
                .getValidator();
    }

}
